﻿
module Sustainalytics.Portfolio {

    import Common = Sustainalytics.Common;
    import SearchBox = Sustainalytics.SearchBox;

    export interface IPortfolioSharedSearchBoxService {
        // Search for items given a term and paging options

        Search(searchData: any, skip: number, take: number): ng.IHttpPromise<any[]>;                  
    }

    export class PortfolioSharedSearchBoxServiceAdapter implements IPortfolioSharedSearchBoxService {

        private portfolioSearchService: PortfolioSearchService;

        public constructor(
            private $http: ng.IHttpService,
            private $rootScope: ng.IScope,
            private $q: ng.IQService) {

            this.portfolioSearchService = new Sustainalytics.Portfolio.PortfolioSearchService($http, $rootScope, $q);
        }

        public Search(searchData: any, skip: number, take: number): ng.IHttpPromise<any[]> {        

           var lstPromise: ng.IHttpPromise<PortfolioDto[]> = this.portfolioSearchService.SearchScreeningToolPortfolio(searchData, skip, take);         

           return lstPromise;
        }
    }

    var mod = angular.module(portfolioModuleName);

    mod.service('PortfolioSharedSearchBoxServiceAdapter',
        ['$http', '$rootScope','$q', PortfolioSharedSearchBoxServiceAdapter]);
}